package com.gsit.expenditure.client.domina;

import java.io.IOException;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.stage.Stage;

public class FXMLBase<T> {
	private FXMLLoader fxmlLoader;
	private Stage dialogStage;
	private Parent root;
	private T controller;
	
	private BooleanProperty stateChange = new SimpleBooleanProperty(Boolean.FALSE);
	
	public FXMLBase(FXMLLoader fxmlLoader){
		this.fxmlLoader = fxmlLoader;
		try {
			root = (Parent) fxmlLoader.load();
			controller = fxmlLoader.getController();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		/*stateChange.addListener(new ChangeListener<Boolean>() {

			@Override
			public void changed(ObservableValue<? extends Boolean> arg0,
					Boolean oldValue, Boolean newValue) {
				if(newValue && dialogStage.isShowing()){
					dialogStage.hide();
				}
				
			}
		});*/
	}
	
	public Parent getRoot() {
		return root;
	}

	public void setRoot(Parent root) {
		this.root = root;
	}

	public void setFxmlLoader(FXMLLoader fxmlLoader) {
		this.fxmlLoader = fxmlLoader;
	}

	public FXMLLoader getFxmlLoader() {
		return fxmlLoader;
	}
	
	public Stage getDialogStage() {
		return dialogStage;
	}
	public void setDialogStage(Stage dialogStage) {
		this.dialogStage = dialogStage;
	}
	public T getController() {
		return controller;
	}
	public void setController(T controller) {
		this.controller = controller;
	}
	
	
	

}
